package com.example.demo.entity.vo;
import com.example.demo.enums.StatusCodeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @description：接口响应结果.
 * @author：lw
 * @create_time：2024/1/4
 **/

@Schema(description = "响应结果")
@Data
public class ResponseResult <dataT>{
    ResponseResult(Integer code,String message,dataT data){
        this.code=code;
        this.message=message;
        this.data=data;
    }
    ResponseResult(){}

    @Schema(description = "业务状态码")
    private Integer code;
    @Schema(description = "响应消息")
    private String message;
    @Schema(description = "响应数据")
    private dataT data;


    public static <dataT> ResponseResult<dataT> build(dataT data, StatusCodeEnum statusCodeEnum){
        return new ResponseResult<>(statusCodeEnum.getCode(),statusCodeEnum.getMessage(),data);
    };

    public static <dataT> ResponseResult<dataT> build(dataT data, Integer code, String message){
        return new ResponseResult<>(code,message,data);
    };
}
